import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDERBase } from './ipsderbase';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDERBaseImpl extends PSModelObjectImpl implements IPSDERBase {
  get codeName(): string {
    return this.M.codeName;
  }

  get dERType(): 'DER1N' | 'DERINHERIT' | 'DERINDEX' | 'DER11' | 'DERMULINH' | 'DERCUSTOM' | 'DERAGGDATA' {
    return this.M.dERType;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  protected majorpsdataentity: IPSDataEntity | null = null;

  getMajorPSDataEntity(): IPSDataEntity | null {
    if (this.majorpsdataentity != null) return this.majorpsdataentity;
    const value = this.M.getMajorPSDataEntity;
    if (value == null) {
      return null;
    }
    this.majorpsdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getMajorPSDataEntity') as IPSDataEntity;
    return this.majorpsdataentity;
  }

  get majorPSDataEntity(): IPSDataEntity | null {
    return this.getMajorPSDataEntity();
  }

  getMajorPSDataEntityMust(): IPSDataEntity {
    const value = this.getMajorPSDataEntity();
    if (value == null) {
      throw new Error('未指定主实体');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  get minorCodeName(): string {
    return this.M.minorCodeName;
  }

  protected minorpsdataentity: IPSDataEntity | null = null;

  getMinorPSDataEntity(): IPSDataEntity | null {
    if (this.minorpsdataentity != null) return this.minorpsdataentity;
    const value = this.M.getMinorPSDataEntity;
    if (value == null) {
      return null;
    }
    this.minorpsdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getMinorPSDataEntity') as IPSDataEntity;
    return this.minorpsdataentity;
  }

  get minorPSDataEntity(): IPSDataEntity | null {
    return this.getMinorPSDataEntity();
  }

  getMinorPSDataEntityMust(): IPSDataEntity {
    const value = this.getMinorPSDataEntity();
    if (value == null) {
      throw new Error('未指定关系实体');
    }
    return value;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSDERBaseImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.der.IPSDERBase') return true;
    return super.instanceof(cls);
  }
}
